import request from '@/utils/request'

// 获取部门
export function getDepartmentsDataApi () {
  return request('/company/department')
}

// 删除部门
export function delDepartmentByIdApi (id) {
  return request.delete(`/company/department/${id}`)
}

// 新增部门
export function addDepartmentApi ({ name, code, manager, introduce }, pid) {
  return request({
    method: 'post',
    url: '/company/department',
    data: {
      name, code, manager, introduce, pid
    }
  })
}

/**
 * @description: 获取部门详情
 * @param {*} id 表示当前要编辑项的id值
 * @return {*}
 */
export function getDepartDetailApi (id) {
  return request({
    url: `/company/department/${id}`
  })
}

/**
  * @description: 更新部门数据
  * @param {*} data:form表单数据 但是要有id值
  * @return {*}
  */
export function updateDepartments (data) {
  return request({
    url: `/company/department/${data.id}`,
    method: 'put',
    data
  })
}
